using System.Security.Cryptography.X509Certificates;
public class FluidBlock : BlockMaterial
{
    public FluidBlock(string Name = "water") : base(Name)
    {
        DisPlayName = "水方块";
        CanBreak = false;
        CanReplace = true;
        StateMax = 7;
        Collide=false;
        TickEvent = Tick;
    }
    public void Tick(UpdataTickEvent e)
    {
        //0:完整水方块
        //1:水方块
        //2:流动水
        if (e.eqBottom("air") || (e.eqBottom(Name) && e.BottomBlock().State > 2))
        {
            e.BottomBlock().SetBlock(this, 2);
        }
        if (e.block.State < 2)
        {
            bool et = e.eqTop(Name);
            if (e.block.State == 0 && et)
            {
                e.block.SetState(1);
            }
            else if (e.block.State == 1 && !et)
            {
                e.block.SetState(0);
            }
        }
        if (e.block.State == 2)
        {
            if (!e.eqTop(Name))
            {
                e.block.SetBlock(Materials.Air);
                return;
            }
        }

        if (e.block.State > 2 &&
            !e.eqTop(Name) &&
            !(e.eqLeft(Name) && e.LeftBlock().State < e.block.State) &&
            !(e.eqRight(Name) && e.RightBlock().State < e.block.State)
            )
        {
            e.block.SetBlock(Materials.Air);
            return;
        }
        if (e.block.State < 6 && !e.eqBottom(Name))
        {
            int s = e.block.State + 1;
            if (e.block.State <= 2) s = 3;
            if (e.eqLeft("air") || (e.eqLeft(Name) && e.LeftBlock().State > e.block.State))
            {
                e.LeftBlock().SetBlock(Materials.Water,s);
            }
            if (e.eqRight("air") || (e.eqRight(Name) && e.RightBlock().State > e.block.State))
            {
                e.RightBlock().SetBlock(this,s);
            }
        }
    }
}